package com.ruoyi.vplat.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.vplat.domain.VplatGateway;
import com.ruoyi.vplat.service.IVplatGatewayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网关Controller
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/vplat/gateway")
public class VplatGatewayController extends BaseController
{
    @Autowired
    private IVplatGatewayService vplatGatewayService;
    
    /**
     * 查询网关列表
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:list')")
    @GetMapping("/queryList")
    public TableDataInfo queryList(@RequestParam Map<String, Object> param) throws Exception
    {
		startPage();
		List<Map<String, Object>> list = vplatGatewayService.queryList(param);
		return getDataTable(list);
    }

    /**
     * 查询网关列表
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:list')")
    @GetMapping("/list")
    public TableDataInfo list(VplatGateway vplatGateway)
    {
        startPage();
        List<VplatGateway> list = vplatGatewayService.selectList(vplatGateway);
        return getDataTable(list);
    }

    /**
     * 导出网关列表
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:export')")
    @Log(title = "网关", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VplatGateway vplatGateway)
    {
        List<VplatGateway> list = vplatGatewayService.selectList(vplatGateway);
        ExcelUtil<VplatGateway> util = new ExcelUtil<VplatGateway>(VplatGateway.class);
        util.exportExcel(response, list, "网关数据");
    }

    /**
     * 获取网关详细信息
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(vplatGatewayService.selectById(id));
    }

    /**
     * 新增网关
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:add')")
    @Log(title = "网关", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VplatGateway vplatGateway)
    {
        return toAjax(vplatGatewayService.insert(vplatGateway));
    }

    /**
     * 修改网关
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:edit')")
    @Log(title = "网关", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VplatGateway vplatGateway)
    {
        return toAjax(vplatGatewayService.update(vplatGateway));
    }

    /**
     * 删除网关
     */
    @PreAuthorize("@ss.hasPermi('vplat:gateway:remove')")
    @Log(title = "网关", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(vplatGatewayService.deleteByIds(ids));
    }
}
